home *** CD-ROM | disk | FTP | other *** search
/ 3D World 76 / 3DWI76.iso / pc / Tutorials.dir / 00020_Script_QuickTime Control Slider < prev    next >
Text File  |  2006-02-08  |  3KB  |  93 lines

  1. -- QuickTime - Control Slider 
  2. -- Used in conjunction with the "Animation: Interactive - Constrain to Line"
  3. -- behavior, allows a QuickTime sprite to be controlled by
  4. -- a slider (and to have the slider move in response to movie
  5. -- playback).
  6. -- v1 - 14 October 1998 by Darrel Plant
  7. -- 7 January 2000:  added isOKToAttach handler and removed resulting redundant
  8. --                   error checking code - Karl Miller
  9.  
  10. on getBehaviorDescription
  11.   return \
  12.     "QuickTime Control Slider" & RETURN & RETURN & \
  13.     "Use this behavior in conjunction with the Animation: Interactive 'Constrain to Line' behavior to create a slider control for QuickTime digital videos. " & \
  14.     "Attach the 'Constrain' behavior to the slider and set its parameters and put this behavior on the digital video sprite." & RETURN & RETURN & \
  15.     "PARAMETERS:" & RETURN & \
  16.     " - channel number of Slider sprite." & RETURN & RETURN & \
  17.     "PERMITTED TYPES:" & RETURN & \
  18.     "#QuickTimeMedia"
  19. end getBehaviorDescription
  20.  
  21. on getBehaviorTooltip me
  22.   return \
  23.     "Use in conjunction with the Constrain to Line behavior (in the Animation > Interactive library) to create a slider that can respond to QuickTime playback."
  24. end getBehaviorTooltip
  25.  
  26. -- PROPERTIES --
  27.  
  28. property pSprite               -- digital video sprite object
  29. property pDuration             -- digital video length (ticks)
  30. -- author-defined properties
  31. property pSliderSprite         -- channel for digital video slider
  32.  
  33. -- EVENT HANDLERS --
  34.  
  35. on beginSprite me
  36.   mInitialize me
  37. end beginSprite
  38.  
  39. on prepareFrame me
  40.   mUpdate me
  41. end prepareFrame
  42.  
  43. -- CUSTOM HANDLERS --
  44.  
  45. on mInitialize me
  46.   -- cache sprite object
  47.   pSprite = sprite (me.spriteNum)
  48.   -- determine length of digital video
  49.   pDuration = pSprite.duration
  50. end mInitialize
  51.  
  52. on mUpdate
  53.   -- convert current movie time to float value from 0 to 1
  54.   vValue = float (pSprite.movietime) / pDuration
  55.   -- send slider message containing new setting value, FALSE
  56.   -- flag indicates that slider will not send new value back to
  57.   -- this sprite
  58.   sendSprite (pSliderSprite, #mSetConstrainPos, vValue, FALSE)
  59. end mUpdate
  60.  
  61. on mConstrainedValue me, vSlider, vValue
  62.   -- check to see if the correct slider sprite is
  63.   -- sending us a message
  64.   if vSlider = pSliderSprite then
  65.     -- set current movie time to slider value times movie length
  66.     pSprite.movieTime = integer (pDuration * vValue)
  67.   end if
  68. end mConstrainedValue
  69.  
  70.  
  71. -- AUTHOR-DEFINED PARAMETERS --
  72.  
  73. on isOKToAttach (me, aSpriteType, aSpriteNum)
  74.   case aSpriteType of
  75.     #graphic:
  76.       return getPos([#quickTimeMedia], sprite(aSpriteNum).member.type) <> 0
  77.     #script:
  78.       return FALSE
  79.    end case
  80. end isOKToAttach
  81.  
  82. on getPropertyDescriptionList me
  83.   if not the currentSpriteNum then
  84.     -- behavior has been attached to script channel
  85.     exit
  86.   end if
  87.   vPDList = [:]
  88.   setaProp vPDList, #pSliderSprite, [#comment: "Slider Sprite", \
  89.     #format: #integer, #default: the currentSpriteNum + 1, \
  90.     #range: [#min: 1, #max: the lastChannel]]
  91.   return vPDList
  92. end getPropertyDescriptionList
  93.